package com.lry.basic.juc;

public class CacheLinePadding1 {
    private static class Padding{
        public long p1,p2,p3,p4,p5,p6,p7;
    }
    private static class T extends Padding{
        public volatile long i;
    }

    public static T x = new T();
    public static T y = new T();

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for(long i=0;i<1000_0000L;++i){
                    x.i = i;
                }
            }
        });
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for(long i=0;i<1000_0000L;++i){
                    y.i = i;
                }
            }
        });
        long start = System.currentTimeMillis();
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(System.currentTimeMillis()-start);
    }
}
